package com.gzr.demo01.threadestate;

//礼让线程-Yield
//礼让不一定成功
public class TestYield {
    public static void main(String[] args) {
        new Thread(new Yield(),"a").start();
        new Thread(new Yield(),"b").start();
    }
}

class Yield implements  Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"线程执行开始");
        //礼让线程
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"线程执行结束");
    }
}
